package com.gress.shop.shiro;


import com.gress.shop.util.MD5Util;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;


/**
 * 进行前台密码的验证 交给shiro的ToolReaml去使用
 * Created by xiongwen on 2017/8/31.
 */
public class MD5Matcher extends SimpleCredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        UsernamePasswordToken passwordToken = (UsernamePasswordToken) token;
        String pass = String.valueOf(passwordToken.getPassword());
        String MD5 = MD5Util.MD5(pass);
        passwordToken.setPassword(MD5.toCharArray());
        // fixme chosse next
//        return true;
        return super.doCredentialsMatch(passwordToken, info);
    }
}

